using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace Zjh
{
    /// <summary>
    /// generate by msg tool
    /// 游戏恢复消息
    /// </summary>
	public class ResRestoreMsg : ResMessage
	{
		//庄家
		public long dealer;
		//0:没有准备,非0:准备
		public int readied;
		//锅底：每副牌玩家所有下注之和(包括比牌的)
		public long totalBetedChips;
		//当前局数
		public int curRound;
		//上一家是否是暗注:0:不是,非0:是
		public int preDark;
		//上一家下注
		public long preBet;
		//下一个操作玩家
		public long nextOptPlayer;
		//0:不可以确认解散房间,非0:请求解散房间的玩家
		public long reqDisbandPlayer;
		//同意解散的玩家
		public List<long> agreeDisbandPlayers = new List<long>();
		
		//下注历史
		public List<long> betedChipsHistory = new List<long>();
		

        public ResRestoreMsg() { }

        public ResRestoreMsg(long dealer, int readied, long totalBetedChips, int curRound, int preDark, long preBet, long nextOptPlayer, long reqDisbandPlayer)
        {
            this.dealer = dealer;
            this.readied = readied;
            this.totalBetedChips = totalBetedChips;
            this.curRound = curRound;
            this.preDark = preDark;
            this.preBet = preBet;
            this.nextOptPlayer = nextOptPlayer;
            this.reqDisbandPlayer = reqDisbandPlayer;
        }

        
		public void write(object obj)
		{
            ByteBuffer b = obj as ByteBuffer;
			b.PushLong(dealer);
			b.PushInt(readied);
			b.PushLong(totalBetedChips);
			b.PushInt(curRound);
			b.PushInt(preDark);
			b.PushLong(preBet);
			b.PushLong(nextOptPlayer);
			b.PushLong(reqDisbandPlayer);
			b.PushInt(agreeDisbandPlayers.Count);

			foreach (var element in agreeDisbandPlayers)
			{
				b.PushLong(element);
				
			}
			b.PushInt(betedChipsHistory.Count);

			foreach (var element in betedChipsHistory)
			{
				b.PushLong(element);
				
			}
			
		}

	    public void read(object obj)
		{
            MyConverter b = obj as MyConverter;
			dealer = b.toInt64();
			readied = b.toInt32();
			totalBetedChips = b.toInt64();
			curRound = b.toInt32();
			preDark = b.toInt32();
			preBet = b.toInt64();
			nextOptPlayer = b.toInt64();
			reqDisbandPlayer = b.toInt64();
			int agreeDisbandPlayers_length = b.toInt32();
			for (int i = 0; i < agreeDisbandPlayers_length; ++i)
			{
				agreeDisbandPlayers.Add(b.toInt64());
				
			}
			int betedChipsHistory_length = b.toInt32();
			for (int i = 0; i < betedChipsHistory_length; ++i)
			{
				betedChipsHistory.Add(b.toInt64());
				
			}
			
		}

		public int Id
		{
            get { return 519235; }
		}

        public String Desc
        {
            get { return "游戏恢复消息"; }
        }
	}
}